#include <algorithm>
#include <fstream>

#include "Generator.h"

Generator::Generator(std::string name, int prop, int prior)
	: name(name), property(prop), priority(prior)
{
	checker = new PropertyChecker();
}

Generator::~Generator()
{
	delete checker;
}

Query *Generator::createQuery(std::vector <OperatorNode *> :: iterator it)
{
	Query *q = new Query(*it);

	createQuery(++it, q, query);

	return q;
}

void Generator::createQuery(std::vector <OperatorNode *> :: iterator it, Query *q, Query *based)
{
	for (unsigned int i = 0; i < based->lists.size(); i++)
	{
		q->addOperator(*it++);

		if (it != opsList.end())
		{
			createQuery(it, q->lists[i], based->lists[i]);
		}
	}
}

int Generator::getProperty()
{
	return property;
}

bool Generator::operator < (const Generator &g)
{
	return priority < g.priority;
}